find_package(PkgConfig)
if (PkgConfig_FOUND)
        pkg_search_module( PC_GSTREAMER_APP gstreamer-app-1.0 )
#        pkg_check_modules(GLIB2 IMPORTED_TARGET glib-2.0)
endif()

find_library(GSTREAMER_APP_LIBRARY
             NAMES gstapp-1.0
             HINTS ${PC_GSTREAMER_APP_LIBDIR} ${GSTREAMER_ROOT_DIR}/lib)

#find_path( GSTREAMER_APP_INCLUDE_DIR
#        NAMES
#                gstreamer.h
#        HINTS
#                "${PC_GSTREAMER_INCLUDEDIR}"
#                "${GSTREAMER_ROOT_DIR}/include"
#        PATH_SUFFIXES
#                gstreamer-1.0
#                gstreamer-1.0/gst
#                gstreamer-1.0/include
#        PATHS
#                /opt/gnome/include
#                /opt/local/include
#                /sw/include
#                /usr/include
#                /usr/local/include
#)

#get_filename_component( gstreamerLibDir "${GSTREAMER_LIBRARY}" PATH)

if(PC_GSTREAMER_APP_VERSION)
        set(GSTREAMER_APP_VERSION ${PC_GSTREAMER_APP_VERSION})
#elseif(GLIB2_INTERNAL_INCLUDE_DIR)
#        # On systems without pkg-config (e.g. Windows), search its header
#        # (available since the initial commit of GLib).
#        file(STRINGS ${GLIB2_INTERNAL_INCLUDE_DIR}/glibconfig.h GLIB_MAJOR_VERSION
#                REGEX "#define[ ]+GLIB_MAJOR_VERSION[ ]+[0-9]+")
#        string(REGEX MATCH "[0-9]+" GLIB_MAJOR_VERSION ${GLIB_MAJOR_VERSION})
#        file(STRINGS ${GLIB2_INTERNAL_INCLUDE_DIR}/glibconfig.h GLIB_MINOR_VERSION
#                REGEX "#define[ ]+GLIB_MINOR_VERSION[ ]+[0-9]+")
#        string(REGEX MATCH "[0-9]+" GLIB_MINOR_VERSION ${GLIB_MINOR_VERSION})
#        file(STRINGS ${GLIB2_INTERNAL_INCLUDE_DIR}/glibconfig.h GLIB_MICRO_VERSION
#                REGEX "#define[ ]+GLIB_MICRO_VERSION[ ]+[0-9]+")
#        string(REGEX MATCH "[0-9]+" GLIB_MICRO_VERSION ${GLIB_MICRO_VERSION})
#        set(GLIB2_VERSION ${GLIB_MAJOR_VERSION}.${GLIB_MINOR_VERSION}.${GLIB_MICRO_VERSION})
else()
        # When using VERSION_VAR it must be set to a valid value or undefined to
        # mean "not found". It's not enough to use the empty string or any other CMake false boolean.
        unset(GSTREAMER_APP_VERSION)
endif()

include( FindPackageHandleStandardArgs )
find_package_handle_standard_args( MyGstreamerApp
        REQUIRED_VARS   GSTREAMER_APP_LIBRARY
        VERSION_VAR     GSTREAMER_APP_VERSION
)

if( MyGstreamerApp_FOUND )
            #set ( GLIB2_DLLS
            #        "${GLIB2_DLL_DIR}/glib-2.0-0.dll"
            #)

            #set ( GLIB2_LIBS
            #        "${GLIB2_LIB_DIR}/glib-2.0.lib"
            #)

            #set ( GLIB2_PDBS
            #        "${GLIB2_DLL_DIR}/glib-2.0-0.pdb"
            #)
elseif( MyGstreamerApp_FIND_REQUIRED )
	message( SEND_ERROR "Package required but not found" )
else()
 #       set( GLIB2_DLL_DIR )
 #       set( GLIB2_PDBS )
        #set( GLIB2_DLLS )
endif()

